// Copyright (c) 2012 Alex Imsha http://imsha.ru
// Use jQuery Library
// imOverlabel - to hide the text in the input when the focus
// http://im-jquery-tools.googlecode.com/svn/trunk/jquery.imoverlabel
(function($) {
    $.fn.imOverlabel = function() {        
        function overlabel(parent,children){
            this.parent = parent;
            this.children = children;
        };
        overlabel.prototype.hide = function(){
            this.parent.css('text-indent','-9999px');
        };
        overlabel.prototype.show = function(){
            this.parent.css('text-indent','0px');
        };
        
        return this.each(function() {
            var id = '#'+$(this).attr('for');
            var children = $(id);
            var parent = $(this);
            var label = new overlabel(parent,children);
            
            if (children.val()){
                label.hide();
            };
            
            children.focusin(function(){
                label.hide();
            });
            children.focusout(function(){
                var value = $(this).val();
                if(!value) {
                    label.show();
                } else {
                    label.hide();
                };
            });
        });
    };
})(jQuery);